<?php
include 'header.php';
include 'Token.php';
include 'codeBack.config.php';
include 'connectMysql.php';
include 'empty.php';
$user_name = $_POST['user_name'];
$user_pass = $_POST["user_pass"];
if(!$user_name || !$user_pass){
	exit();
}
$user_pass = md5($user_pass);
$sql = "SELECT * FROM ac_user WHERE user_name='$user_name' AND user_pass='$user_pass'";
$result = $mysqli->query($sql);
$row = mysqli_fetch_object($result);

//if($row){
//}
/*
if($row){
	...
}else{

}
 */

if($row->user_name == $user_name && $row->user_pass == $user_pass){
	// 查询成功
	$data = [
		"code"=>$CodeBack["LOGIN_SUCCESS_CODE"],
		"user_id"=>$row->user_id,
		"user_name"=>$row->user_name,
		"user_img"=>$row->user_img,
		"token"=>$row->token,
		"message"=>"登录成功",
	];
	echo json_encode($data);
}else {
	if($row->user_name != $user_name || $row->user_pass != $user_pass){
		$data = [
			"code"=>$CodeBack["LOGIN_FAILED_CODE"],
			"message"=>"账号或者密码不对",
		];
		echo json_encode($data);
	}else{
		$data = [
			"code"=>$CodeBack["LOGIN_FAILED_CODE"],
			"message"=>"账号密码不存在,请去注册"
		];
		echo json_encode($data);
	}
}




